package com.lhk.appframework;

import com.lhk.appframework.factory.FactoryApp;
import com.lhk.appframework.factory.FactoryAppDefault;
import com.lhk.appframework.factory.FactoryEngine;
import com.lhk.appframework.factory.FactoryManager;
import com.lhk.appframework.factory.FactoryPresenter;
import com.lhk.appframework.manager.ManagerAppUser;
import com.lhk.appframework.manager.ManagerHttp;
import com.lhk.appframework.manager.ManagerMap;
import com.lhk.appframework.manager.ManagerSharedPreferences;
import com.lhk.appframework.utils.UtilsLog;

import android.app.Application;

public class MyApplication extends Application {
	
	
	public static MyApplication instance;
	
	
	private FactoryApp factoryApp;
	
	private ManagerAppUser managerAppUser;
	private ManagerMap managerMap;
	private ManagerHttp managerHttp;
	private ManagerSharedPreferences managerSP;
	
	private FactoryEngine factoryEngine;
	private FactoryPresenter factoryPresenter;
	private FactoryManager factoryManager;
	
	
	@Override
	public void onCreate() {
		super.onCreate();
		instance = this;
		
		UtilsLog.setDebug(true);
		
		factoryApp = FactoryAppDefault.getInstance();
		
		
		init();
	}

	
	public void init(){
		
		factoryEngine = factoryApp.getFactoryEngine();
		factoryPresenter = factoryApp.getFactoryPresenter();
		factoryManager = factoryApp.getFactoryManager();
		
		
		managerSP = factoryManager.getManagerSharedPreferences(this);
		managerAppUser = factoryManager.getManagerAppUser(this);
		
		managerHttp = factoryManager.getManagerHttp();
		
		initMap();
		
	}
	
	public void initMap(){
		managerMap = factoryApp.getFactoryManager().getManagerMap(this);
//		managerMap.startLocation();
		
	}
	

	public static MyApplication getInstance() {
		return instance;
	}


	public FactoryApp getFactoryApp() {
		return factoryApp;
	}


	public ManagerAppUser getManagerAppUser() {
		return managerAppUser;
	}


	public ManagerMap getManagerMap() {
		return managerMap;
	}


	public ManagerHttp getManagerHttp() {
		return managerHttp;
	}


	public FactoryEngine getFactoryEngine() {
		return factoryEngine;
	}


	public FactoryPresenter getFactoryPresenter() {
		return factoryPresenter;
	}


	public FactoryManager getFactoryManager() {
		return factoryManager;
	}


	public ManagerSharedPreferences getManagerSP() {
		return managerSP;
	}
	
	
}
